﻿Imports System.Data.OleDb

Public Class AddMerchandise
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btn_add_Click(sender As Object, e As EventArgs) Handles btn_add.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("godzillaFilms").ConnectionString)
        Dim sql = "INSERT INTO Merchandise (ItemType, Description, Picture, FanName) VALUES (@f1, @f2, @f3, @f4)"
        Dim myGUID = Guid.NewGuid()
        Dim newFileName As String = ""
        newFileName = myGUID.ToString() & ".jpg"
        Dim fileLocation = Request.MapPath("MerchPictures") & "/" & newFileName
        fup_picture.SaveAs(fileLocation)
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", ddl_type.SelectedValue)
        cmd.Parameters.AddWithValue("@f2", tb_description.Text)
        cmd.Parameters.AddWithValue("@f3", "MerchPictures/" & newFileName)
        cmd.Parameters.AddWithValue("@f4", User.Identity.Name)
        cmd.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("MerchandiseList.aspx")
    End Sub
End Class